package org.example.copyClass;

import com.google.common.collect.Lists;
import org.springframework.beans.BeanUtils;

import java.util.List;

public class ConvertClass {
    public static void main(String[] args) {
        User user1 = new User(1L, "张三", 25);
        User user2 = new User(2L, "李四", 18);
        User user3 = new User(3L, "王五", 20);
        List<User> userList = Lists.newArrayList(user1, user2, user3);

        List<UserDTO> userDTOList = Lists.newArrayList();
        for (User user : userList) {
            UserDTO userDTO = new UserDTO();
            BeanUtils.copyProperties(user, userDTO);
            userDTOList.add(userDTO);
        }


        System.out.println("UserDTO: " + userDTOList);
    }
}
